import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import path from 'path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import { resolve } from 'node:path'
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(__dirname, 'src/assets/icons/avg')],
      symbolId: 'icon-[dir]-[name]',
    })
   
  ],
  //配置@位src目录
  resolve: {
    alias: {
     // '@': fileURLToPath(new URL('./src', import.meta.url))
     //__dirname 当前脚本所在的目录
     //'@': path.resolve(__dirname,'./src')
     '@':path.resolve(__dirname,'src')
    },
  },

  server:{
    open :true ,//浏览器自动访问
   // port: 8899,
    proxy:{
      '/api':{
        target:'http:localhost:8080',
         changeOrigin:true,
         rewrite:(path)=>path.replace(/^\/api/,""),
      }
    }
  }
})
